package com.dataextend.service;


import com.alibaba.fastjson.JSONObject;
import com.dataextend.entity.MarketDetailRequest;
import com.dataextend.mapper.cluster.MarketMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *  推送效果详情
 */
@Service
public class MarketDetailService {
    @Autowired
    MarketMapper marketMapper;

    public JSONObject marketDetail(MarketDetailRequest marketDetailRequest){
        JSONObject obj = new JSONObject();
        if (marketDetailRequest.getMissionType().equals("邮件")){
            obj = marketMapper.marketEmailDetail(marketDetailRequest.getGroupId(), marketDetailRequest.getAddTime());
        } else if (marketDetailRequest.getMissionType().equals("短信")){
            obj = marketMapper.marketMessageDetail(marketDetailRequest.getGroupId(), marketDetailRequest.getAddTime());
        } else {
            obj = marketMapper.marketPushDetail(marketDetailRequest.getGroupId(), marketDetailRequest.getAddTime());
        }
        JSONObject detailInfo = new JSONObject(true);
        String groupName = obj.getString("group_name");
        detailInfo.put("groupName", groupName);
        String missionName = obj.getString("mission_name");
        detailInfo.put("missionName", missionName);
        String messageInfo = obj.getString("message_info");
        detailInfo.put("messageInfo", messageInfo);
        String creater = obj.getString("creater");
        detailInfo.put("creater", creater);
        String sendTime = obj.getString("send_time");
        detailInfo.put("sendTime", sendTime);
        String startDate = obj.getString("start_date");
        detailInfo.put("startDate", startDate);
        String endDate = obj.getString("end_date");
        detailInfo.put("endDate", endDate);
        String targetNum = obj.getString("target_num");
        detailInfo.put("targetNum", targetNum);
        String sendNum = obj.getString("send_num");
        detailInfo.put("sendNum", sendNum);
        String clickNum = obj.getString("click_num");
        detailInfo.put("clickNum", clickNum);
        String dealNum = obj.getString("deal_num");
        detailInfo.put("dealNum", dealNum);

        return detailInfo;
    }


}
